import 'package:loxen/api/api.dart';
import 'package:rxdart/rxdart.dart';


enum ReportType{
  IDEA_ARTICLE,
  COMMENT,
}

mixin ReportMixin {


  Stream<int> report(String id, String type, String content,ReportType reportType){
    if(reportType == ReportType.IDEA_ARTICLE) {
      return reportIdeaArticle(id, type, content);
    }else if(reportType == ReportType.COMMENT) {
      return reportComment(id, type, content);
    }
    return Stream.value(-1);
  }

  //举报灵感  201
  Stream<int> reportComment(String id, String type, String content) {
    return ApiService.report(content, id, "users-comment", type)
        .flatMap((event) => Stream.value(event.statusCode));
  }

  //举报灵感  201
  Stream<int> reportIdeaArticle(String id, String type, String content) {
    return ApiService.report(content, id, "idea-article", type)
        .flatMap((event) => Stream.value(event.statusCode));
  }
}
